class Factory {
    private final FruitCollection fruitCollection = new FruitCollection();

    public Fruit CreateFruit(String kind) {
        Fruit fruit = null;
        if ("A".equals(kind)) {
            fruit = new Apple();
        } else if ("B".equals(kind)) {
            fruit = new Banana();
        }

        if(fruit != null) {
            fruitCollection.addFruit(fruit);
        }
        return fruit;
    }

    public FruitIterator getIterator() {
        return fruitCollection.createIterator();
    }
}